using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Mvp.Xml;
using System.Xml.XPath;
using Mvp.Xml.Common;


namespace CSDesktopUsiXMLRenderer
{
    class ResourceRetriever
    {
        private XmlNode resourceModel = null;

        public ResourceRetriever(XmlNode resourceModel)
        {
            this.resourceModel = resourceModel;
        }

        public String getStringResourceContent(XmlNode node)
        {
            XmlElement element = (XmlElement)node;

            String cioId = element.GetAttribute("id");
            String content = null;

            XmlNodeReader reader = new XmlNodeReader(this.resourceModel);
            
            String expression = "//resourceModel/cioRef[@cioId='" + cioId + "']/resource/@content";

            XPathDocument doc = new XPathDocument(reader);
            XPathNavigator docnav = doc.CreateNavigator();
            XPathExpression xpath = docnav.Compile(expression);

            Object conteudo = docnav.Evaluate(xpath);

            String name = element.GetAttribute("name");
            if (name == "button_1")
            {
                return "1";
            }
            if (name == "button_2")
            {
                return "2";
            }
            if (name == "button_3")
            {
                return "3";
            }
            if (name == "button_4")
            {
                return "4";
            }
            if (name == "button_5")
            {
                return "5";
            }
            if (name == "button_6")
            {
                return "6";
            }
            if (name == "button_7")
            {
                return "7";
            }
            if (name == "button_8")
            {
                return "8";
            }
            if (name == "button_9")
            {
                return "9";
            }
            if (name == "button_0")
            {
                return "0";
            }
            if (name == "button_Plus")
            {
                return "+";
            }
            if (name == "button_Minus")
            {
                return "-";
            }
            if (name == "button_Mult")
            {
                return "*";
            }
            if (name == "button_Div")
            {
                return "/";
            }
            if (name == "button_Equals")
            {
                return "=";
            }
           

            content = "";

            return content;
        }

    }
}
